﻿//https://ac.nowcoder.com/acm/problem/202487

#include <iostream>
using namespace std;
int t;
int h, a, H, A;
int fun()
{
    if (a >= H) return -1;
    int m = (H / a) + (H % a != 0 ? 1 : 0); // 怪物能抗⼏次
    int n = m - 1; // 玩家被攻击⼏次
    int x = n * A; // 杀死⼀只怪物的时候，玩家会掉多少⾎
    int ret = h / x - (h % x == 0 ? 1 : 0);
    return ret;
}
int main()
{
    cin >> t;
    while (t--)
    {
        cin >> h >> a >> H >> A;
        cout << fun() << endl;
    }
    return 0;
}



//https://www.nowcoder.com/questionTerminal/9fbb4d95e6164cd9ab52e859fbe8f4ec

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {

    int N;
    cin >> N;
    vector<string> strings(N);
    for (int i = 0; i < N; ++i) {
        cin >> strings[i];
    }
    set<string> st;
    for (const auto& str : strings) {

        string sortedStr = str;
        sort(sortedStr.begin(), sortedStr.end());
        st.insert(sortedStr);
    }
    cout << st.size() << endl;

    return 0;
}

//hash
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_set>
using namespace std;
int n;
string s;
int main()
{
    cin >> n;
    unordered_set<string> hash;
    while (n--)
    {
        cin >> s;
        sort(s.begin(), s.end());
        hash.insert(s);
    }
    cout << hash.size() << endl;
    return 0;
}




//https://www.nowcoder.com/practice/71cde4dee669475f94d8d38832374ada?tpId=196&tqId=40411&ru=/exam/oj
class Solution {
public:
    void dfs(int city, vector<vector<int>>& m, vector<bool>& visited) {
        visited[city] = true;
        for (int j = 0; j < m.size(); ++j) {
            if (m[city][j] == 1 && !visited[j]) { //如果城市相连并且未访问
                dfs(j, m, visited);
            }
        }
    }
    int citys(vector<vector<int> >& m) {
        int n = m.size();
        vector<bool> visited(n, false);
        int citycount = 0;

        for (int i = 0; i < n; ++i) {
            if (!visited[i]) {
                dfs(i, m, visited);
                citycount++;
            }
        }

        return citycount;
    }
};